package bot.pojo;

import lombok.Data;

@Data
public class RPGgame {
    public static String printHealthBar(int currentHealth, int maxHealth) {
        double healthPercentage = (double) currentHealth / maxHealth;
        int barLength = 20;

        int filledLength = (int) (healthPercentage * barLength);
        int emptyLength = barLength - filledLength;

        String filledBar = repeatString("█", filledLength);
        String emptyBar = repeatString("-", emptyLength);
        String bloodStr = "[" + filledBar + emptyBar + "]";
        System.out.println("血量最大值:"+maxHealth +"|剩余血量:"+currentHealth);
        System.out.println(bloodStr);
        return bloodStr;
    }
    private static String repeatString(String str, int times) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < times; i++) {
            sb.append(str);
        }
        return sb.toString();
    }
}
